package struts.action.account;

import java.util.ArrayList;
import java.util.List;

import org.apache.struts2.json.annotations.JSON;

import spring.bean.UserService;
import struts.action.dto.SexDTO;
import hibernate.model.object.Sex;

public class SexAction {
	private List<SexDTO> sexs = new ArrayList<SexDTO>();
	private UserService userService;
	
	@JSON(name="sex")
	public List<SexDTO> getSexs() {
		return sexs;
	}
	public void setSexs(List<SexDTO> sexs) {
		this.sexs = sexs;
	}
	
	@JSON(serialize=false)
	public UserService getUserService() {
		return userService;
	}
	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	
	
	
	public String execute(){
		List<Sex> sexModel = userService.getSexData();
		for(int i=0;i<sexModel.size();i++){
			SexDTO sexDTO = new SexDTO();
			sexDTO.setId(sexModel.get(i).getId());
			sexDTO.setGender(sexModel.get(i).getGender());
			sexs.add(sexDTO);
		}
		return "success";
	}
	
}
